(function($) {
    var vm = new Vue({
        el: '#J_tongji',
        data: function() {
            return {
                total: '0.00',
                tongji: {},
                date: '',
                is_first_request: true
            }
        },
        watch: {
            date: function(newDate, oldDate) {
                if (!this.is_first_request) {
                    this.getList(newDate)
                } else {
                    this.getList('')
                    this.is_first_request = false
                }
            }
        },
        created: function() {    
            const myDate = new Date()
            this.date = myDate.getFullYear() + '-' + (myDate.getMonth()*1 + 1)
            // this.getList(this.date)
        },
        mounted: function() {
            const _this = this;
            new Mdate("dateSelectorOne", {
                acceptId: "dateSelect",
                beginYear: '2017',
                format: "-",
                vm: _this
            })
        },
        methods: {
            getList: function(date) {
                const _this = this;
                var shop_id = $.getQueryString('shop_id') || ''
                $.mAjax({
                    url: '/order/get-cancel-count',
                    data: {
                        cancel_time: date,
                        shop_id: shop_id
                    },
                    success: function(res) {
                        if(res.status == 1) {
                            _this.tongji = res.data
                            _this.total = res.data.experience_total
                        } else {
                            if (res.error.errorno == '401') {
                                layer.open({
                                    content: '登录过期，请重新登录！',
                                    skin: 'msg',
                                    time: 2 //2秒后自动关闭
                                })
                                setTimeout(function () {
                                    localStorage.removeItem('_u_info_')
                                    location.href = './index.html'
                                }, 2000)
                            }
                        }
                    }
                })
            }
        },
        filters: {
            hide: function (tel) {
                return tel.substr(0, 3) + '****' + tel.substr(7, 11)
            }
        }
    })
})(jQuery)